import { http } from "@/utils/http";
import { baseUrlApi } from "../utils";

type Result = {
  status: number;
  msg: string;
  success: boolean;
};

type ResultOrganization = {
  success: boolean;
  data?: {
    items: Array<any>;
    list: Array<any>;
    totalCount: number;
  };
  msg: string;
};

type ResultUserId = {
  success: boolean;
  data?: string;
};

//获取所有机构-下拉框
export const GetAllOrganization = (data?: object) => {
  return http.request<ResultOrganization>(
    "get",
    baseUrlApi("/Organization/GetAllOrganization"),
    { data }
  );
};

//根据组班级Id和代表队Id获取对应学生
export const GetPageStu = (params?: object) => {
  return http.request<ResultOrganization>(
    "get",
    baseUrlApi("/ZSUser/GetPageStu"),
    {
      params
    }
  );
};

//根据班级Id获取学生账号
export const GetStuByClass = (params?: string) => {
  return http.request<ResultOrganization>(
    "get",
    baseUrlApi("/ZSUser/GetStuByClassId?" + params)
  );
};

/** 根据机构Id获取教师列表 */
export const GetPage = (params?: object) => {
  return http.request<ResultOrganization>(
    "get",
    baseUrlApi("/ZSUser/GetPageTea"),
    {
      params
    }
  );
};

//获取最新的新增用户ID
export const GetNewUserId = (params?: object) => {
  return http.request<ResultUserId>("get", baseUrlApi("/ZSUser/GetNewUserId"), {
    params
  });
};

//删除教师
export const Delete = (params?: object) => {
  return http.request<Result>("post", baseUrlApi("/ZSUser/Delete"), {
    params
  });
};

//保存
export const Save = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/ZSUser/Save"), {
    data
  });
};

export const SaveStudent = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/ZSUser/SaveStudent"), {
    data
  });
};

export const BatchAddStu = (data?: object) => {
  return http.request<Result>("post", baseUrlApi("/ZSUser/BatchAddStu"), {
    data
  });
};

// 权限管理 statr
// 获取权限列表
export const PlanTemplatePermissionsGetPageData = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/PlanTemplatePermissions/GetPageData"),
    {
      data
    }
  );
};

// 删除信息
export const DeletePlanTemplatePermissions = (params?: string) => {
  return http.request<Result>(
    "get",
    baseUrlApi("/PlanTemplatePermissions/Delete?" + params)
  );
};

// 获取添加计划权限信息基础数据
export const PlanTemplatePermissionsGetAddOrUpdateBaseData = () => {
  return http.request<any>(
    "get",
    baseUrlApi("/PlanTemplatePermissions/GetAddOrUpdateBaseData")
  );
};

// 修改or添加 权限信息
export const PlanTemplatePermissionsAddOrUpdate = (data?: object) => {
  return http.request<any>(
    "post",
    baseUrlApi("/PlanTemplatePermissions/AddOrUpdate"),
    {
      data
    }
  );
};

// 权限管理 end

// 初始化数据
export const ServiceDataDataInit = () => {
  return http.request<any>("post", baseUrlApi("/ServiceData/DataInit"));
};
